package com.ang.exception;

/**
 * 测试自定义异常
 */
public class ExceptionTest02 {
    public static void main(String[] args) {
        ExceptionTest02 t = new ExceptionTest02();

//        t.t1(0);
//        t.t2(0);

        try {
            t.t1(0);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("------------------------------");
            System.out.println(e.getMessage());
        }

        System.out.println("==================================");

        try {
            t.t2(0);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("------------------------------");
            System.out.println(e.getMessage());
        }

    }

    public void t1(Integer i){
        try {
            int r = 10 / i;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public void t2(Integer i){
        try {
            int r = 10 / i;
        } catch (Exception e) {
            throw new CustomException("传参有误");
        }
    }
}
